<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      4.3.&nbsp;Adding the LFS User
    </title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="lfs" id="lfs-7.3">
    <div class="navheader">
      <h4>
        Linux From Scratch - Version 7.3
      </h4>
      <h3>
        Chapter&nbsp;4.&nbsp;Final Preparations
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="creatingtoolsdir.html" title=
          "Creating the $LFS/tools Directory">Prev</a>
          <p>
            Creating the $LFS/tools Directory
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="settingenvironment.html" title=
          "Setting Up the Environment">Next</a>
          <p>
            Setting Up the Environment
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter04.html" title=
          "Chapter&nbsp;4.&nbsp;Final Preparations">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 7.3">Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="ch-tools-addinguser" name="ch-tools-addinguser"></a>4.3.
        Adding the LFS User
      </h1>
      <p>
        When logged in as user <code class="systemitem">root</code>, making a
        single mistake can damage or destroy a system. Therefore, we
        recommend building the packages in this chapter as an unprivileged
        user. You could use your own user name, but to make it easier to set
        up a clean working environment, create a new user called <code class=
        "systemitem">lfs</code> as a member of a new group (also named
        <code class="systemitem">lfs</code>) and use this user during the
        installation process. As <code class="systemitem">root</code>, issue
        the following commands to add the new user:
      </p>
      <pre class="userinput">
<kbd class="command">groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs</kbd>
</pre>
      <div class="variablelist">
        <p class="title">
          <b>The meaning of the command line options:</b>
        </p>
        <dl>
          <dt>
            <span class="term"><em class="parameter"><code>-s
            /bin/bash</code></em></span>
          </dt>
          <dd>
            <p>
              This makes <span class="command"><strong>bash</strong></span>
              the default shell for user <code class="systemitem">lfs</code>.
            </p>
          </dd>
          <dt>
            <span class="term"><em class="parameter"><code>-g
            lfs</code></em></span>
          </dt>
          <dd>
            <p>
              This option adds user <code class="systemitem">lfs</code> to
              group <code class="systemitem">lfs</code>.
            </p>
          </dd>
          <dt>
            <span class="term"><em class=
            "parameter"><code>-m</code></em></span>
          </dt>
          <dd>
            <p>
              This creates a home directory for <code class=
              "systemitem">lfs</code>.
            </p>
          </dd>
          <dt>
            <span class="term"><em class="parameter"><code>-k
            /dev/null</code></em></span>
          </dt>
          <dd>
            <p>
              This parameter prevents possible copying of files from a
              skeleton directory (default is <code class=
              "filename">/etc/skel</code>) by changing the input location to
              the special null device.
            </p>
          </dd>
          <dt>
            <span class="term"><em class=
            "parameter"><code>lfs</code></em></span>
          </dt>
          <dd>
            <p>
              This is the actual name for the created group and user.
            </p>
          </dd>
        </dl>
      </div>
      <p>
        To log in as <code class="systemitem">lfs</code> (as opposed to
        switching to user <code class="systemitem">lfs</code> when logged in
        as <code class="systemitem">root</code>, which does not require the
        <code class="systemitem">lfs</code> user to have a password), give
        <code class="systemitem">lfs</code> a password:
      </p>
      <pre class="userinput">
<kbd class="command">passwd lfs</kbd>
</pre>
      <p>
        Grant <code class="systemitem">lfs</code> full access to <code class=
        "filename">$LFS/tools</code> by making <code class=
        "systemitem">lfs</code> the directory owner:
      </p>
      <pre class="userinput">
<kbd class="command">chown -v lfs $LFS/tools</kbd>
</pre>
      <p>
        If a separate working directory was created as suggested, give user
        <code class="systemitem">lfs</code> ownership of this directory:
      </p>
      <pre class="userinput">
<kbd class="command">chown -v lfs $LFS/sources</kbd>
</pre>
      <p>
        Next, login as user <code class="systemitem">lfs</code>. This can be
        done via a virtual console, through a display manager, or with the
        following substitute user command:
      </p>
      <pre class="userinput">
<kbd class="command">su - lfs</kbd>
</pre>
      <p>
        The &ldquo;<span class="quote"><em class=
        "parameter"><code>-</code></em></span>&rdquo; instructs <span class=
        "command"><strong>su</strong></span> to start a login shell as
        opposed to a non-login shell. The difference between these two types
        of shells can be found in detail in <code class=
        "filename">bash(1)</code> and <span class="command"><strong>info
        bash</strong></span>.
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="creatingtoolsdir.html" title=
          "Creating the $LFS/tools Directory">Prev</a>
          <p>
            Creating the $LFS/tools Directory
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="settingenvironment.html" title=
          "Setting Up the Environment">Next</a>
          <p>
            Setting Up the Environment
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter04.html" title=
          "Chapter&nbsp;4.&nbsp;Final Preparations">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 7.3">Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
